<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>专业信息管理</title>
	<meta name="decorator" content="default"/>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="专业管理" />
	<tags:message content="${message}"/>
    <div class="page-content">
    	<div class="search-block" style="display:none;">
			<form:form id="searchForm" modelAttribute="majorInfo" action="${ctx}/school/majorInfo/" method="post" class="form-horizontal">
				<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
				<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<div class="form-group" style="margin-bottom: 0px;">
					<div class="col-sm-2">
						<form:input path="majorName" htmlEscape="false" maxlength="32" class="col-sm-12" placeholder="专业名称"/>
					</div>
					<div class="col-sm-2">
						<form:select path="majorLevel" class="col-sm-12 chosen-select required">
							<form:option value="" label="--专业层次--"/>
							<form:options items="${fns:getDictList('zy_cc')}" itemLabel="label" itemValue="value" htmlEscape="false" placeholder="专业层次"/>
						</form:select>
					</div>
					<div class="col-sm-2">
						<form:select path="majorParentCode" cssClass="col-sm-12 required chosen-select">
							<form:option value="" label="--请选择专业大类--"/>
							<form:options items="${fns:getDictList('major_parent_code')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</div>
					<div class="col-sm-2">
						<form:select path="majorType" class="col-sm-12 required chosen-select">
							<form:option value="" label="--请选择专业类别--"/>
							<form:options items="${fns:getDictList('major_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</div>
					<div class="col-sm-4">
						<div style="float: right;margin-right: 10px;">
							<input id="btnSubmit" class="btn btn-primary btn-sm" type="submit" value="查询"/>&nbsp;
							<input id="btnExport" class="btn btn-inversn btn-sm" type="button" value="导出"/>&nbsp;
							<input id="btnImport" class="btn btn-warning btn-sm" type="button" value="导入"/>
						</div>
					</div>
				</div>
			</form:form>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>专业名称</th>
				<th>专业层次</th>
				<th>专业大类</th>
				<th>专业类别</th>
				<th>专业代码</th>
				<th>修学年限</th>
				<th>授予学位</th>
				<th>专业排名</th>
				<th>更新人员</th>
				<th>更新时间</th>
				<shiro:hasPermission name="school:majorInfo:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="majorInfo">
			<tr>
				<td><a href="${ctx}/school/majorInfo/form?id=${majorInfo.id}">
					${majorInfo.majorName}
				</a></td>
				<td>
					${fns:getDictLabel(majorInfo.majorLevel, 'zy_cc', '本科')}
				</td>
				<td>
                    ${fns:getDictLabel(majorInfo.majorParentCode, 'major_parent_code', '无')}
				</td>
				<td>
					${fns:getDictLabel(majorInfo.majorType, 'major_type', '无')}
				</td>
				<td>
					${majorInfo.majorCode}
				</td>
				<td>
					${fns:getDictLabel(majorInfo.studyLife, 'study_life', '四年')}
				</td>
				<td>
					${fns:getDictLabel(majorInfo.awardDegree, 'award_degree', '学士学位')}
				</td>
				<td>
					${majorInfo.majorSort}
				</td>
				<td>
					${majorInfo.updateBy}
				</td>
				<td>
					<fmt:formatDate value="${majorInfo.updateDate}" pattern="yyyy-MM-dd"/>
				</td>
				<shiro:hasPermission name="school:majorInfo:edit"><td>
    				<a href="${ctx}/school/majorInfo/form?id=${majorInfo.id}" class="btn btn-info btn-mini">修改</a>
					<a href="javascript:;" class="btn btn-danger btn-mini" onclick="deleteMsg('确认要删除该专业信息吗？','${ctx}/school/majorInfo/delete?id=${majorInfo.id}',this);">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">学校导入</h4>
			</div>
			<div class="modal-body">
				<form id="importForm" action="${ctx}/school/majorInfo/import" enctype="multipart/form-data"  method="post" class="form-horizontal">
					<div class="form-group">
						<label class="col-sm-2 no-padding-right control-label">模板名称:</label>
						<div class="col-sm-8">
							<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>
							<span class="important">*</span>
						</div>
						<div col-sm-2>
							<a href="${ctx}/school/majorInfo/import/template">下载模板</a>
						</div>
					</div><hr>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" id="btnSureImport">确定</button>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
        //显示高级查询
		$(".search-block").show();
        $(".search_link").click(function(){
            if($(".search-block").is(":visible")){
                $(".search-block").hide();
                $(".search_link").text("高级查询");
            }else{
                $(".search-block").show();
                $(".search_link").text("隐藏查询");
            }
        });

        //导出
        $("#btnExport").click(function(){
            layer.confirm("确认要导出专业数据吗？",function(index){
                layer.close(index);
                $("#searchForm").attr("action","${ctx}/school/majorInfo/export");
                $("#searchForm").submit();
            });
        });

        //导入
        $("#btnImport").click(function(){
            $("#myModal").modal({
                backdrop:"static"
            });
        });

        //确定导入
        $("#btnSureImport").click(function(){
            $("#importForm").submit();
        });
	});

    function deleteMsg(msg,href,tr){
        layer.confirm(msg,{icon:5,title:"温馨提示"},function(index){
            loading();
            layer.close(index);
            $.post(href,function(data){
                if(data.success){
                    showNote("success", function () {
                        $(tr).parent().parent().remove();
                    }, data.msg, "center");
                }else {
                    showNote("error", function () {
                        return false;
                    }, data.msg);
                }
            });
        });
    }

	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
</script>
</body>
</html>